package com.ztf.sequenceflow;

import java.util.HashMap;
import java.util.Map;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.runtime.ProcessInstance;
import org.junit.Test;

public class SequenceFlowTest {
    @Test
    public void testDeploy(){
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        processEngine.getRepositoryService()
                .createDeployment()
                .addClasspathResource("com/itheima09/activiti5/sequenceflow/sequenceflow.bpmn")
                .deploy();
    }

    @Test
    public void testStartPI(){
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        ProcessInstance pi = processEngine.getRuntimeService()
                //.startProcessInstanceByKey(processDefinitionKey)  根据pdkey启动流程实例  默认根据最高版本的启动
                .startProcessInstanceById("sequence:1:3704");
        System.out.println(pi.getId());
        System.out.println(pi.getProcessInstanceId());
        System.out.println(pi.getProcessDefinitionId());
    }

    @Test
    public void testFinishTask(){
        Map<String, Object> variables = new HashMap<String, Object>();
        variables.put("message","不重要");
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        processEngine.getTaskService()
                .complete("3902",variables);
    }
}